package com.wg.wuge.tulin.jmm;

public class JmmTest {

    //即使添加volatile 也不一定总是10000；因为volatile不能解决原则性问题.
    private static int counter = 0;

    public static void main(String[] args) {
        for (int i = 0; i < 10 ; i++) {
            Thread thread = new Thread(() -> {
                for (int j = 0 ; j < 1000; j++) {
                    counter ++;
                }
            });
            thread.start();
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(counter);
    }
}
